package week4.num.ExceptionDemo01.Level4_Project10;

import java.util.Scanner;

public class App {
    public static void main(String[] args) {
        int result;
        try {
            result = getResult();
            System.out.println(result);
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (ArrayIndexOutOfBoundsException e) {
            e.printStackTrace();
        } catch (ArithmeticException e) {
            e.printStackTrace();
        } finally {
            System.out.println("总是被执行");
        }
    }

    public static int getResult() throws ArrayIndexOutOfBoundsException {

        Scanner sc = new Scanner(System.in);
        System.out.println("请输入两个整数");
        String num1 = sc.nextLine();
        String num2 = sc.nextLine();
        if (num1.equals("") || num2.equals("")) {
            throw new ArrayIndexOutOfBoundsException();
        }
        int number1 = Integer.parseInt(num1);
        int number2 = Integer.parseInt(num2);


        int result = number1 / number2;
        return result;
    }
}